import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { NewService } from '../service/new.service';
import { CreateNewDto } from '../dto/new/create-new.dto';
import { UpdateNewDto } from '../dto/new/update-new.dto';
import { ListNewDto } from '../dto/new/list-new.dto';

@Controller('grocery/new')
export class NewController {
  constructor(private readonly newService: NewService) {}

  @Post('insert')
  create(@Body() createNewDto: CreateNewDto) {
    return this.newService.create(createNewDto);
  }

  @Post('list')
  findAll(@Body() listNewDto: ListNewDto) {
    return this.newService.findAll(listNewDto);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.newService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateNewDto: UpdateNewDto) {
    return this.newService.update(+id, updateNewDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.newService.remove(+id);
  }
}
